package game.DecuryMan
{
	import flash.display.Loader;
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	public class DecuryMan2 extends Loader
	{
		
		
		
		public function DecuryMan2()
		{
			super();
		}
		
		public function addDrag():void{
			this.addEventListener(MouseEvent.MOUSE_DOWN, drag);
			this.addEventListener(MouseEvent.MOUSE_UP, dragup);
			
		}
		
		public function drag(evt:MouseEvent):void{
			
			this.parent.removeChild(this);
			this.parent.addChild(this);
			this.addEventListener(MouseEvent.MOUSE_MOVE, dragmove);
			//Alert.show(this.x + " ");
			//Alert.show(evt.localX +  " ");
			
			
		}
		
		public function dragmove(evt:MouseEvent):void{
			this.x = evt.stageX - 200 - ChessMain.gridW/2;
			this.y = evt.stageY - 50 - ChessMain.gridW/2;
		}
		
		
		public function dragup(evt:MouseEvent):void{
			this.removeEventListener(MouseEvent.MOUSE_MOVE,dragmove);
		}
		
		
		
		
		
		
	}
}